package com.garbuz.svnadmin.view
{
	import com.garbuz.svnadmin.data.Permission;

	import flash.text.engine.FontWeight;

	import mx.containers.Canvas;
	import mx.events.FlexEvent;

	public class PermissionItemBase extends Canvas
	{
		[Bindable]
		public var labelText:String;

		[Bindable]
		public var labelColor:uint;

		[Bindable]
		public var descriptionText:String;

		[Bindable]
		public var labelFont:String;

		public function PermissionItemBase()
		{
			addEventListener(FlexEvent.DATA_CHANGE, onDataChange)
		}

		private function onDataChange(event:FlexEvent):void
		{
			var permission:Permission = Permission(data);

			if (permission)
			{
				labelText = permission.label;
				descriptionText = permission.description;
				labelColor = permission.isGroup ? 0x806080 : 0x000000;
				labelFont = permission.isGroup ? FontWeight.BOLD : FontWeight.NORMAL;
			}
		}
	}
}
